package com.jetinno.net;

import android.text.TextUtils;

import com.jetinno.utils.JsonUtil;
import com.jetinno.utils.LogUtils;
import com.jetinno.utils.PrintHelper;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * Created by zhangyuncai on 2021/10/25.
 */
public class ReceivedMsgBean implements Serializable {
    private static final String TAG = "ReceivedMsgEvent";
    private String cmd;
    private int ret;
    private String order_no;
    private String qr_type;
    private String qrcode;
    private String paytype;
    private String operation;
    private String dir;
    private String type;
    private int fastcode;
    private int product_id;
    private int product_amount;
    private int Amount;
    private int discount;
    private boolean paydone;
    private long vmc_no;
    private List<List<Integer>> price;
    private String carrier_code;//客户编号
    private Map<String,String> supply; // 添加物料

    public static ReceivedMsgBean newMsgEvent(String message) {
        ReceivedMsgBean event = JsonUtil.jsonToAny(message, ReceivedMsgBean.class);
        if (event == null || TextUtils.isEmpty(event.getCmd())) {
            LogUtils.d(TAG, "消息解析错误" + " 消息源:" + message + " 原因：event==null");
            return null;
        }
        PrintHelper.printLayoutJson(message);
        return event;
    }

    public void setCmd(String cmd) {
        this.cmd = cmd;
    }

    private String nonNull(String text) {
        if (text == null) {
            return "";
        }
        return text;
    }

    public String getCmd() {
        return nonNull(cmd);
    }

    public int getRet() {
        return ret;
    }

    public String getOrderNo() {
        return nonNull(order_no);
    }

    public String getQrType() {
        return nonNull(qr_type);
    }

    public String getQrCode() {
        return nonNull(qrcode);
    }

    public String getPayType() {
        return nonNull(paytype);
    }

    ///远程操作类型
    public String getOperation() {
        return nonNull(operation);
    }

    ///下载地址链接
    public String getDir() {
        return nonNull(dir);
    }

    ///下载地址类型
    public String getType() {
        return nonNull(type);
    }

    public int getFastCode() {
        return fastcode;
    }

    public int getProductId() {
        return product_id;
    }

    public int getProductAmount() {
        return product_amount;
    }

    ///取货码价格
    public int getAmount() {
        return Amount;
    }

    ///远程修改价格
    public int getDiscount() {
        return discount;
    }

    public boolean getPayDone() {
        return paydone;
    }

    ///机器号
    public long getVmcNo() {
        return vmc_no;
    }

    /**
     * cmd : priceset
     * price : [[102,1190,0],[246,1090,0],[283,1290,0],[103,990,0],[105,890,0],[204,890,0],[240,1090,0],[701,990,0],[704,690,0],[802,990,0],[931,890,0],[104,1190,0],[800,690,0],[810,1,0]]
     * vmc_no : 33333
     */
    public List<List<Integer>> getPrice() {
        return price;
    }

    public String getCarrier_code() {
        return carrier_code;
    }

    public Map<String, String> getSupply() {
        return supply;
    }
}
